<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8"/>
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <title>维修管理--维修信息管理</title>

    <link href="../plugin/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="../plugin/bootstrap-table-1.11.1/bootstrap-table.min.css" rel="stylesheet"/>
    <link href="../plugin/sweetalert-6.6.2/sweetalert2.min.css" rel="stylesheet"/>
    <link href="../plugin/jstree/jstree.min.css" rel="stylesheet">

    <script src="../plugin/jquery-3.2.1/jquery-3.2.1.min.js"></script>
    <script src="../plugin/bootstrap-3.3.7/js/bootstrap.min.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/bootstrap-table.js"></script>
    <script src="../plugin/bootstrap-table-1.11.1/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="../plugin/sweetalert-6.6.2/sweetalert2.min.js"></script>
    <script src="../plugin/jquery-3.2.1/jquery.formautofill.min.js"></script>
    <script src="../plugin/soul/utils3.js"></script>
    <script src='../js/base.js'></script>
    <script src="../plugin/jquery-3.2.1/jquery.serializejson.js"></script>
    <script src="../plugin/jstree/jstree.min.js"></script>
    <script src="../plugin/wangEditor-3.0.15/wangEditor.min.js"></script>
</head>

<body>

<div class="modal fade" data-backdrop="static" id="staffManager_modal_edit_detail">
    <div class="modal-dialog modal-lg ">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
                <h4 class="modal-title">
                    <b>维修故障描述</b>
                </h4>
            </div>
            <div class="modal-body">
                <div id="staffManager_modal_edit_detail_editor"></div>
            </div>
            <div class="modal-footer">
                <button class="btn btn-default" data-dismiss="modal">取消</button>
                <button class="btn btn-primary" onclick="repairRecord.faultDescribe.save()">保存</button>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        var resp = AjaxUtil.isLogin();
        if (!resp) return;
        var module = 'repairRecord';// 维修模块
        var query = [{
            id: 'equipmentName',
            type: 'text',
            name: '设备名称',
            paramName: 'equipmentName',
            palceholder: ''
        }, {
            id: 'equipmentSerial',
            type: 'text',
            name: '设备序列号',
            paramName: 'equipmentSerial',
            palceholder: ''
        }, {
            id: 'eqiupmentModel',
            type: 'text',
            name: '设备型号',
            paramName: 'eqiupmentModel',
            palceholder: ''
        },{
            id: 'departmentName',
            type: 'text',
            name: '科室',
            paramName: 'departmentName',
            palceholder: ''
        },{
            id: 'errorCode',
            type: 'text',
            name: '错误码',
            paramName: 'errorCode',
            palceholder: ''
        }, {
            id: 'repairStatus',
            type: 'select',
            name: '维修状态',
            paramName: 'repairStatus',
            items: [{
                name: '院内维修',
                value: 1
            }, {
                name: '返厂维修',
                value: 2
            }, {
                name: '技术中心维修',
                value: 3
            }, {
                name: '待医院确认',
                value: 4
            }, {
                name: '退回',
                value: 5
            }]
        }];
        var toolbar = {
            default: [false, false, false, false],// back;add;edit;remove
            dialog: [50, 2, 9],//对话框参数:模态框宽度(百分比);表单标题宽度;表单输入框宽度
            extra: [{
                name: '故障描述',
                glyphicon: 'list',
                onclick: 'showFaultDescribe',
            }]
        };
        var formElement = [];

        var bootstrapTable = {
            url: '',
            columns: [{
                radio: true
            }, {
                field: 'acceptanceStatus',
                title: '维修进度',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '未完成';
                    } else if (value == 2) {
                        return '待验收';
                    } else if (value == 3) {
                        return '已完成';
                    } else {
                        return '未知';
                    }
                }
            },{
                field: 'repairStatus',
                title: '维修状态',
                formatter: function (value, row, index) {
                    if (value == 1) {
                        return '院内维修';
                    } else if (value == 2) {
                        return '返厂维修';
                    } else if (value == 3) {
                        return '技术中心维修';
                    } else if (value == 4) {
                        return '待医院确认';
                    } else if (value == 5) {
                        return '退回';
                    }else {
                        return '未知';
                    }
                }
            }, {
                field: 'hospitalName',
                title: '医院名称',
                align: 'center',
            }, {
                field: 'departmentName',
                title: '所在科室',
                align: 'center',
            }, {
                field: 'equipmentName',
                title: '设备名称',
                align: 'center',
            },{
                field: 'eqiupmentModel',
                title: '设备型号',
                align: 'center',
            }, {
                field: 'equipmentSerial',
                title: '设备序列号',
                align: 'center',
            },  {
                field: 'staffName',
                title: '工程师',
                align: 'center',
            }, {
                field: 'applyDate',
                title: '报修时间',
                align: 'center',
                formatter: BootstrapTableUtil.formatter.datetime
            }, {
                field: 'repairDate',
                title: '修复时间',
                align: 'center',
                formatter: BootstrapTableUtil.formatter.datetime
            }, {
                field: 'accessoryDescribe',
                title: '备件信息描述',
                align: 'center',
            }, {
                field: 'errorCode',
                title: '错误码',
                align: 'center',
            }, {
                field: 'faultPhoto',
                title: '故障图片',
                align: 'center',
                formatter: function (value, row, index) {
                    if (value) {
                        var path;
                        var html = "";
                        var photoStr = value.split('-');// 多图切割
                        for (var i = 0; i < photoStr.length-1; i++) {
                            path =photoStr[i];
                            html += '<a href="'+path+'" target="_blank"><img height="50px" src="' + path + '" style="padding: 5px"></a>';
                        }
                        return html;
                    } else {
                        return '暂无图片'
                    }

                }
            }, {
                field: 'repairRecordRemark',
                title: '维修记录备注',
                align: 'center',
            } ]
        }

        // debugger;
        repairRecord = SingleTablePageCreateUtil.createInstance(module, query, toolbar, null, bootstrapTable);

        repairRecord.showFaultDescribe = function () {
            var row = TablePageCreatePublicUtil.getRowFromTable('#repairRecord_table');
            if (!row) return false;
            repairRecord.showFaultDescribe.currentId = row.repairRecordId;
            editor.txt.html(row.faultDescribe || '');
            $('.w-e-text-container').css('height', '500px')
            $('#staffManager_modal_edit_detail').modal('show');
        };


        repairRecord.faultDescribe = {};
        repairRecord.faultDescribe.currentId = undefined;
        repairRecord.faultDescribe.save = function () {
            var faultDescribe = editor.txt.html();
            console.log(faultDescribe);
            var resp = AjaxUtil.postJson('repairRecord/editFaultDescribe', {
                repairRecordId: repairRecord.showFaultDescribe.currentId,
                faultDescribe: faultDescribe
            });
            if (resp) {
                SwalUtil.success(resp.msg);
                $('#repairRecord_table').bootstrapTable('refresh');
                $('#staffManager_modal_edit_detail').modal('hide');
                editor.txt.html('');
            }

        };

        var E = window.wangEditor;
        var editor = new E('#staffManager_modal_edit_detail_editor');
        editor.customConfig.uploadImgServer = '/wangEditor/uploadImages?token=' + BaseConfig.token;
        editor.customConfig.uploadFileName = 'file';
        // editor.customConfig.uploadImgMaxLength = 1;
        editor.customConfig.uploadImgTimeout = 3 * 60 * 1000;
        editor.create();

    });
</script>
</body>

</html>